﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace YJKCoordinate
{
	internal class InputChecker : IChecker
	{
		public bool IfCanUse(List<XYZ> inputPoints, CornerKindEnum cornerKindEnum, Dictionary<UseParameterEnum, double> inputValues)
		{
			double num = inputValues[UseParameterEnum.Width];
			switch (cornerKindEnum)
			{
			case CornerKindEnum.SingleChamfer:
				num = Math.Max(num, inputValues[UseParameterEnum.Distance]);
				break;
			case CornerKindEnum.Chamfer:
				num = Math.Max(num, inputValues[UseParameterEnum.Distance]);
				break;
			case CornerKindEnum.ArcAngle:
				num = Math.Max(num, inputValues[UseParameterEnum.Radius]);
				break;
			}
			num = this.coff * num;
			num = Math.Abs(num);
			return this.IfCanUse(inputPoints, num);
		}

		private bool IfCanUse(List<XYZ> inputPoints, double inputValues)
		{
			for (int i = 0; i < inputPoints.Count; i++)
			{
				for (int j = i; j < inputPoints.Count; j++)
				{
					if (i != j && inputPoints[i].DistanceTo(inputPoints[j]) < inputValues)
					{
						return false;
					}
				}
			}
			return true;
		}

		private double coff = 1.2;
	}
}
